package it.datagraf.formazione.hellostruts.struts;

import it.datagraf.formazione.hellostruts.entity.Competenza;
import it.datagraf.formazione.hellostruts.service.CVServiceInteface;
import it.datagraf.formazione.hellostruts.service.CVserviceImpl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class InsertCompetenzeAction extends Action{
	
	public static Log log = LogFactory.getLog(HelloAction.class);
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		try {
			CVServiceInteface cvsI= new CVserviceImpl();
			List<Competenza> cps= cvsI.listComps();
			System.out.println("elenco competenze--------------------------------------------------------------------------------------------");
			for(int i=0;i<cps.size();i++)
			{
				System.out.println("-------------------------------------------------------------------------------------"+cps.get(i).getNome());
			}
			request.setAttribute("cps", cps);
			
		} catch (Throwable e) {
			log.error("ERRORE COMPETENZE",e);
		}
		
		return mapping.findForward("success");
	}

}
